<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML>
<html>
<head>
<title>三尺山教育信息咨询有限公司后台管理系统</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="../../jslib/jquery-easyui-1.3.1/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="../../jslib/jquery-easyui-1.3.1/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../../jslib/jquery-easyui-1.3.1/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../jslib/tools.js"></script>
<link rel="stylesheet" href="../../jslib/jquery-easyui-1.3.1/themes/default/easyui.css" type="text/css"></link>
<link rel="stylesheet" href="../../jslib/jquery-easyui-1.3.1/themes/icon.css" type="text/css"></link>
<style type="text/css">
.myBut {
	border: 1px solid #00FF99;
	background-color: #CCE8CF;
}
</style>
<script type="text/javascript" charset="utf-8">
	$(function() {
		$('#moduls_user_datagrid').datagrid({
			url : '${pageContext.request.contextPath}/appraiseAction!get.action',
			fit : true,
			border : false,
			checkOnSelect : false,
			rownumbers : true,
			pagination : true,
			selectOnCheck : false,
			idField : 'id',
			nowrap : false,
			columns : [ [ {
				title : 'ID',
				field : 'id',
				width : 50,
				hidden : true
			}, {
				title : '新闻ID',
				field : 'newsId',
				width : 200,
				hidden : true
			}, {
				title : '新闻标题',
				field : 'newsName',
				width : 300,
				formatter : function(value,row,index) {
					return '<span title="'+value+'">' + (value.length <= 21 ? value : (value.substring(0, 21) +'...')) +'</span>';
				}
			}, {
				title : '评论内容',
				field : 'message',
				width : 600,
				formatter : function(value,row,index) {
					return '<span title="'+value+'">' + (value.length <= 45 ? value : (value.substring(0, 45) +'...')) +'</span>';
				}
			}, {
				field : 'action1',
				title : '操作',
				width : 80,
				formatter : function(value, row, index) {
					return '<img onclick="query(\''+row.id+'\')" title="查看详细" src="${pageContext.request.contextPath}/jslib/jquery-easyui-1.3.1/themes/icons/search.png">&nbsp;&nbsp;<a href="javascript:void(0)" onclick="del(' + row.id + ')" ><img alt="删除" src="${pageContext.request.contextPath}/jslib/jquery-easyui-1.3.1/themes/icons/icon_trash.gif"></a>';
				}
			} ] ]
		});
		
		
	});
	
	function query(id) {
		var newsName;
		var message;
		$.ajax({
			url : '${pageContext.request.contextPath}/appraiseAction!getById.action',
			data : {
				id : id
			},
			dataType : 'json',
			success : function(result) {
				if (result) {
					$('#modifyDiv').dialog('setTitle',result.newsName);
					$('#modifyDivSpan').text(result.message);
				}
			}
		});
		
		$('#modifyDiv').dialog({
			title : newsName,
			width : 500,
			height : 250,
			closed : false,
			closable : false,
			modal : true,
			buttons : [ {
				text : '取消',
				iconCls : 'icon-edit',
				handler : function() {
					$('#modifyDiv').dialog('close');
				}
			} ]
		});
		
		
	}

	function del(id) {
		$.messager.confirm('确认', '您是否要删除？', function(r) {
			if (r) {
				$.ajax({
					url : '${pageContext.request.contextPath}/appraiseAction!delete.action',
					data : {
						id : id
					},
					dataType : 'json',
					success : function(result) {
						if (result.success) {
							$('#moduls_user_datagrid').datagrid('load');
						}
						$.messager.show({
							title : '提示',
							msg : result.msg
						});
					}
				});
			}
		});
	}
</script>
</head>
<body>
	<table id="moduls_user_datagrid"></table>
	
	<div id="modifyDiv">
	<span id="modifyDivSpan" style="font-weight: normal;"></span>
	</div>
</body>